<?
define('PC', 1);
include("ggheader.php");
include_once("/var/www/html/new/com.inc.php");
include_once('/var/www/html/wx/api/pc_shops/init.php');
include_once("/var/www/html/new/d/class/Member.php");
include_once("/var/www/html/new/d/class/abc/PFTCore777.class.php");

$ac=$GLOBALS['_ac'];
$pw=$GLOBALS['_pw'];
$s = new SoapClient(null,array("location" => "http://localhost/open/openService/pft_insideMX.php","uri" => "www.16u.com?ac_16u=$ac|pw_16u=$pw|auth_16u=true"));
//当是鼓浪屿的二级域名时
if(APPLY_DID==7517){
    include 'gdetail_gly.html';
    exit;
}
$m = new Member($s,APPLY_DID);
$lid = $_REQUEST['lid'];

$sql = <<<SQL
SELECT id,title,address,area,jtype,p_type,imgpath,px,jqts,bhjq,jtzn,jqts
FROM uu_land WHERE id=$lid LIMIT 1
SQL;

$GLOBALS['le']->query($sql);
$data = $GLOBALS['le']->fetch_assoc();
$salePros   = $m->salePros($lid);
foreach($salePros as $k=>$ticket){ // 处理价格

	if($ticket['pay']==0) continue;
    if($channel_sale_f && !in_array($ticket['pid'],$channel_sale_a)) continue;
	
	$pStorage = PFTCore777::Dynamic_Price_And_Storage($s, '', $ticket['pid'], '', $date, 1);
	if($pStorage['ls']['p']==-1) continue;
    $ticket['uprice']  = $pStorage['ls']['p'];
    $ticket['storage'] = $pStorage['ls']['s'];
	
    // 景区信息
    if(!$land['ltitle']){
        $land['p_type'] = $ticket['p_type'];
        $land['ltitle'] = $ticket['title'];
        $land['sapply_did'] = $ticket['sapply_did'];
        if(strpos($ticket['imgpath'],'images.12301.cc'))
            $land['imgpath'] = $ticket['imgpath'];
        else
            $land['imgpath'] = 'http://www.12301.cc/'.$ticket['imgpath'];
    }
    if($ticket['sapply_did']!=$land['sapply_did'])continue;
    $land['tickets'][] = $ticket;
}
if(!count($land)) exit('暂无在线预定产品');
$tickets = array();
$date = date('Y-m-d');
$land = array();

// 渠道过滤
$channel_sale_f = false;
$channel_sale_a =  array();
$sql = "select id from pft_sale_channel where fid=".APPLY_DID." limit 1";
$GLOBALS['le']->query($sql);
if($GLOBALS['le']->fetch_assoc()){
	$channel_sale_f = true;
	$sql = "select pid from pft_sale_channel where lid=$lid and status=0 and find_in_set(2,channel)";
	$GLOBALS['le']->query($sql);
	while($row=$GLOBALS['le']->fetch_assoc()) $channel_sale_a[] = $row['pid'];
}


foreach($salePros as $k=>$ticket){ // 处理价格

	if($ticket['pay']==0) continue;
    if($channel_sale_f && !in_array($ticket['pid'],$channel_sale_a)) continue;
	
	$pStorage = PFTCore777::Dynamic_Price_And_Storage($s, '', $ticket['pid'], '', $date, 1);
	if($pStorage['ls']['p']==-1) continue;
    $ticket['uprice']  = $pStorage['ls']['p'];
    $ticket['storage'] = $pStorage['ls']['s'];
	
    // 景区信息
    if(!$land['ltitle']){
        $land['p_type'] = $ticket['p_type'];
        $land['ltitle'] = $ticket['title'];
        $land['sapply_did'] = $ticket['sapply_did'];
        if(strpos($ticket['imgpath'],'images.12301.cc'))
            $land['imgpath'] = $ticket['imgpath'];
        else
            $land['imgpath'] = 'http://www.12301.cc/'.$ticket['imgpath'];
    }
    if($ticket['sapply_did']!=$land['sapply_did'])continue;
    $land['tickets'][] = $ticket;
}
define('DETAIL_LINK','/new/d/shops/gdetail.html');// 详情链接地址
$hot = $saveArr['products']['A'];
if(count($hot)) shuffle($hot);
//print_r($data);
//处理下产品简介
$z = htmlspecialchars_decode($data['bhjq']);
$z = strip_tags($z);
$z1 = mb_substr($z,0,40,'utf-8').'...';

if($_GET['z']){
    print_r($land);

    echo "<hr>";
    echo $z;
    echo "<hr>";
    echo $z1;
    echo "<hr>";
    echo $data['p_type'];
}



?>
<link rel="stylesheet" type="text/css" href="http://www.12301.cc/shops/css/gdetail.css"/>
<div class="ggMainCon ggw1100 clearfix">
    <div class="mainCol l">
        <div id="buyWrap" class="buyWrap clearfix">
            <div class="photoW col l ggshadow"><table class="photoTable"><tr><td><img src="<?=$land['imgpath']?>" alt=""/></td></tr></table></div>
            <div class="col pdetail r">
                <div class="tit line ggellipsis"><?=$land['ltitle']?></div>
                <div class="desc line"><?=$z?></div>
                <div class="price line clearfix">
                    <div class="l col">价格：</div>
                    <div class="r col"><i class="yen">&yen;</i><span id="nprice" class="num"><?=$land['tickets'][0]['uprice']?></span><span id="opricew" class="oldp">原价<span id="nprice">199</span></span></div>
                </div>
                <div class="tclass line clearfix">
                    <div class="l col">选择票类：</div>
                    <div class="r col" id="ticketList">
                        <?foreach($land['tickets'] as $k=>$ticket):?>
                        <span class="tbox<?if($k==0) echo ' active';?>" data-nprice="<?=$ticket['uprice']?>" data-storage="<?=$ticket['storage']?>" data-lid=<?=$lid?> data-tid="<?=$ticket['tid']?>" data-pid="<?=$ticket['pid']?>" data-type="<?=$ticket['p_type']?>" data-aid="<?=$ticket['sapply_did']?>"><?=$ticket['ttitle']?></span>
                        <?endforeach;?>
                    </div>
                </div>
                <div class="date line clearfix">
                    <div class="l col">游玩日期：</div>
                    <div class="r col"><input type="text" class="dateInp" id="dateInp" value="2014-12-20"/><i class="gsprite gicon calder"></i></div>
                </div>
                <div class="count line clearfix">
                    <div class="l col">预订数量：</div>
                    <div class="r col">
                        <div class="countGroup clearfix">
                            <a class="btn minu gsprite gicon minuCount" id="minuCountBtn" href="#"></a>
                            <input class="countInp" id="countInp" type="text" value="1"/>
                            <a class="btn plus gsprite gicon addCount" id="addCountBtn" href="#"></a>
                        </div>
                        <div id="storagew" class="storage">库存：<span id="storageCount" class="storageCount">100</span></div>
                    </div>
                </div>
                <div class="line clearfix btn">
                    <input class="submitBtn buy" id="buyBtn" type="button" value="预订"/>
                    <input class="submitBtn addCart" id="addCartBtn" type="button" value="加入购物车"/>

                </div>
            </div>
        </div>
        <div id="detailWrap" class="detailWrap">
            <ul class="tabHead clearfix">
                <li class="tabLi yunding active">预订须知</li>
                <li class="tabLi jianjie">景点简介</li>
                <li class="tabLi jianjie">交通指南</li>
            </ul>
            <div class="detailCon yunding">
                <?=nl2br($data['jqts']);?>
            </div>
            <div class="detailCon jianjie">
					<?=str_ireplace('src="/prodimgs','src="http://www.12301.cc/prodimgs',htmlspecialchars_decode($data['bhjq']));?>
			</div>
			
            <div class="detailCon zhinan">
                <?=nl2br($data['jtzn'])?>
            </div>
        </div>
    </div>
    <div class="mainCol r gglistGroup col-1">
        <div class="gghd"><span class="col l">为您推荐</span></div>
        <ul class="listUl">
            <?if(count($hot)):$hi=0;?>
            <?foreach($hot as $key=>$hdata):?>
            <?if(!is_array($hdata)) continue;?>
            <?if((++$hi)>5) break;?>
            <li class="ggListItem">
                <div class="photo"><a href="<?=DETAIL_LINK.'?lid='.$hdata['id']?>" target="_blank"><img src="<?=$hdata['imgpath']?>" alt="<?=$hdata['title']?>"/></a></div>
                <div class="bCon">
                    <a class="awrap" href="<?=DETAIL_LINK.'?lid='.$hdata['id']?>" target="_blank">
                        <span class="tit ggellipsis"><?=$hdata['title']?></span>
                        <!--<span class="desc ggellipsis"></span>-->
                        <span class="fw clearfix">
                            <span class="col price l">
                                <span class="p p1">原价：<i class="yen">&yen;</i><span class="num"><?=$hdata['tprice']?></span></span>
                                <span class="p p2">预订价：<i class="yen">&yen;</i><span class="num"><?=$hdata['uprice']?></span></span>
                            </span>
                            <span class="col online r">在线预订</span>
                        </span>
                    </a>
                </div>
            </li>
            <?endforeach;?>
			<?endif;?>
        </ul>
    </div>

</div>
<script>
jQuery(document).ready(function($){
	$(".intro_information").css("width","auto");
})
</script>
<?php include("ggfoot.php");?>
    <span id="movetocartIcon" class="movetocartIcon"></span>
<script type="text/javascript" src="http://www.12301.cc/shops/js/gdetail.js"></script>
</body>